<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--项目名必须写--%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
  <head>
    <title>选择题库编辑</title>

    <style>

    </style>

  </head>
  <body>
    <h2>选择题库编辑管理</h2>
    <div id="edit">
      <form id="edit_selection_form" action="/SelectionAdmin?methodName=addSelection">
        <select name="type">
            <option value="single_choice">单选</option>
            <option value="multi_choice">多选</option>
        </select>
        <br/>
        题目内容：
        <textarea name="content"></textarea>
        <br/>
        选项信息：<br/>
        A:<textarea name="choiceInfo"></textarea><br/>
        B:<textarea name="choiceInfo"></textarea><br/>
        C:<textarea name="choiceInfo"></textarea><br/>
        D:<textarea name="choiceInfo"></textarea><br/>
        <br/>
        正确答案：
        <input type="text" name="answer"/>
        <br/>
        分数：
        <input type="text" name="score"/>
        <br/>
        答案描述：<br/>
        <textarea name="answerInfo"></textarea><br/>
        <input type="submit" value="提交">
      </form>
    </div>

    <script src="${ctx}/common/jquery/jquery-3.5.0.js"></script>
  <script>
      $(document).ready(function(){
          $("#edit_selection_form").submit(function(e){
              var formData = $(this).serialize();
              addSelection(formData);
              return false;
          });
          //方法跳转
          function addSelection(formData){
              $.ajax({
                  url:"${ctx}/SelectionAdmin?methodName=addSelection",
                  data:formData,
                  type:"post",
                  success:function(result){
                      if(result.state == '200'){
                          alert("数据添加成功");
                          window.location.href="${ctx}/examination/common_module/e_selection_admin.jsp";
                      }
                  }
              });
          }
      });
  </script>
  </body>
</html>
